package com.habdqn.studentmanager.bean;

import com.habdqn.studentmanager.constant.DictType;

/**
 * @author Administrator
 * 字典表实体类
 * 2017年5月13日
 * 
 */
public class Dictionary extends Bean {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 字典类型
	 */
	private Integer type;
	
	/**
	 * 字典对应的值
	 */
	private Integer value;
	
	/**
	 * 字典的KEY
	 */
	private String name;

	/**
	 * 备用字段
	 */
	private String ext1;
	
	/**
	 * 备用字段
	 */
	private String ext2;
	
	/**
	 * 备用字段
	 */
	private String ext3;

	public static Dictionary make(DictType type, String name, Integer value) {
		
		Dictionary dict = new Dictionary();
		
		if (null != type) {
			dict.type = type.toInteger();			
		}
		
		dict.name = name;
		dict.value = value;
		return dict;
	}
	
	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Integer getValue() {
		return value;
	}

	public void setValue(Integer value) {
		this.value = value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getExt1() {
		return ext1;
	}

	public void setExt1(String ext1) {
		this.ext1 = ext1;
	}

	public String getExt2() {
		return ext2;
	}

	public void setExt2(String ext2) {
		this.ext2 = ext2;
	}

	public String getExt3() {
		return ext3;
	}

	public void setExt3(String ext3) {
		this.ext3 = ext3;
	}

	@Override
	public boolean equals(Object obj) {
		
		if (obj == null) {
			return false;			
		}
		
		if (this == obj) {
			return true;			
		}
		
		if (getClass() != obj.getClass()) {
			return false;			
		}
		
		Dictionary other = (Dictionary) obj;
		if (!value.equals(other.value)) {
			return false;			
		}
		
		return true;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((ext1 == null) ? 0 : ext1.hashCode());
		result = prime * result + ((ext2 == null) ? 0 : ext2.hashCode());
		result = prime * result + ((ext3 == null) ? 0 : ext3.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		result = prime * result + ((value == null) ? 0 : value.hashCode());
		return result;
	}
}
